package thread;

import java.util.Vector;

public class BigNumberThread {

	public static void main(String[] args) throws InterruptedException {

		int amount = 100000;
		long start = System.currentTimeMillis();
		Vector<Thread> sub = new Vector<Thread>(amount);
		for(int i = 0; i < amount; i++){
			final int index = i;
			Thread t = new Thread(){
				@Override
				public void run() {
					System.out.println(index);
					int number = Integer.MAX_VALUE;
					while(number-- > 0);
				}
			};
			t.start();
			sub.add(t);
		}
		for(int i = 0; i < amount; i++){
			Thread t = sub.get(i);
			if(t.isAlive()){
				t.join();
			}
		}
		long end = System.currentTimeMillis();
		System.out.println("总共花费时间:" + ((double)(end - start) / 1000) + "秒");
	}
}
